package com.atmilan.quartz.utils;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class PictureUtil {

    public static final String ss = "https://1431182383.rsc.cdn77.org/public/Foto/FW18---CéLINE---40058CPLB138NO.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---CéLINE---40059CPEB119HV.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---CéLINE---40059CPEB138NO.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/081---TOD'S---XXM39A0Z070ML1S818.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/081---PHILIPPE MODEL---TRLDUNI1114.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/083---ALEXANDER MCQUEEN---502044()J160K7285 NEW ORO()CR MET.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---GUCCI---5289523G0019888.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---MIU MIU---5I246C959056.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/083---HERNO---PI0670D()121702600 TORTORA.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/081---GIUSEPPE ZANOTTI---I870030STRETCH004.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---CRIME---11308AA1B130.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---SAINT LAURENT---481862YC2NI1000.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---FAY---NAW5037Y050GAHB999GAHC809.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/081---J BRAND---JB0016688314T152HDJ41614.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---CRIME---25465AA1B120.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---GEDEBE---CLIKYNAPPA PRINTRED BURGUNDY.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---CRIME---25451AA1B120.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---MARC ELLIS---MA4007VITELLONERO()ARGENTO.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---MARC ELLIS---MA4047PIEDE POLLIEBIANCO()NERO.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/A45---ALbertA FERRETTI---J032866161306.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---STILL GOOD---SGHATROLLTAPEBOXRED.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---ATTICO---FW18ANKLET5BLACK.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/A45---ALbertA FERRETTI---J062451480040.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/A45---FALLON---FS21601PEONY.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---STILL GOOD---ARROWCAPSRED.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/A45---NaTASHA ZINKO---FW1840405SABINASABINA.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/A45---FALLON---FS21601BEIGE.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/A18---KENZO UOMO---F865CH204 1GE76.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/A18---KENZO DONNA---F862TS757 98501.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---ALBERTA FERRETTI---0416 5118555.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---MONCLER UOMO---84210-00 80451828.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/A18---ERMANNO SCERVINO---D335M331 AHW71328.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/A18---MONCLER DONNA---84566-00 829B5999.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---GIANVITO ROSSI---G7382785RICBLACK.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---STELLA MC CARTNEY by ADIDAS---AC8200B.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---BALMAIN---PF01010 I015C2030.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---BALMAIN---W8H9130 T491176.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---KENZO UOMO---F755TS001 4BA99.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---KENZO DONNA---F862TS757 98593.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---KENZO DONNA---F862CH187 5AP01.jpg," +
            "https://1431182383.rsc.cdn77.org/public/Foto/FW18---KENZO DONNA---F862BL748 95293.jpg";

    public static void main(String[] args) {

        Boolean urlCode = getUrlCode("https://1431182383.rsc.cdn77.org/public/Foto/081---CALVIN KLEIN---K10K102747UNI304.jpg");
        System.out.println(urlCode);
        /*String[] sUrl = ss.split(",");
        for(String url : sUrl){
            getUrlCode(url);
        }*/
    }
    public static Boolean getUrlCode(String posturl){
        while(true){
            try {
                if(posturl == "" || posturl == null || StringUtils.isBlank(posturl)){
                    return  false;
                }
                String newUrl = posturl.replace(" ", "%20");
                URL url = new URL(newUrl);
                HttpURLConnection urlcon = (HttpURLConnection) url.openConnection();
                urlcon.setConnectTimeout(60 * 1000);
                System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
                urlcon.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
                //urlcon.setRequestMethod("GET");
                if (urlcon.getResponseCode() == HttpURLConnection.HTTP_OK) {
                    System.out.println(true + ":" +newUrl);
                    log.warn(posturl + ":T       R       U      E");
                    return true;
                } else {
                    System.out.println(false + ":" +newUrl);
                    log.warn(posturl + ":F       A       L      S        E");
                    return false;
                }
            }catch (IOException e){
                log.info(e.getMessage(), e,posturl);
                if (true){
                    continue;
                }
            }
        }
    }
}
